set matsize 10000

use panel, clear

// muslim indicator and interactions
gen muslim=(parentalg==1|parenttun==1|parentmor==1|parenttur==1)  					
drop if nat28pr==14|nat28pr==60|nat28pr==61 				
gen y04=(surveyr>=2004)																
drop if surveyr>=2013
gen inter=muslim*y04

tab surveyr, gen(yr_)
sum surveyr, det
local max=r(max)-r(min)+1
disp `max'
forval y=1/`max' {
	gen inter_`y'=yr_`y'*muslim
}

// difference in student status
gen student=(acteu6==5)
replace student=. if acteu6==.
gen diffstud=student-L2.student
la var diffstud "Student status, difference from previous qtr"
gen Lforniv=L2.forniv
gen Lstudent=L2.student
keep if trim=="4"

gen temp1=(Lforniv<=6&surveyr<2008)		// forniv=6 is tertiary from 2008 onwards
gen temp2=(Lforniv<6&surveyr>=2008)


local depvar diffstud
local sample if ag>=16&Lforniv>2&(temp1==1|temp2==1)&Lforniv!=.&Lstudent==1&lnais==1&child==1&female==1
local cl nat28pr
estimates clear
reg `depvar' i.nat28pr i.ag##i.muslim i.surveyr inter_* i.birthyear `sample'&female==1, cluster(`cl')
eststo c1
coefplot (c1, ciopts(lcolor(black) recast(rcap)) mcolor(black) color(red)), ///
omitted keep(inter_*) ci(90) vertical yline(0, lcolor(gs5)) xline(2, lcolor(gs10)) recast(bar) barwidth(0.25) fcolor(*.5) ///
coeflabels(inter_1="2003" inter_2="2004" inter_3="2005" inter_4="2006" inter_5="2007" inter_6="2008" ///
inter_7="2009" inter_8="2010" inter_9="2011" inter_10="2012") xtitle("Survey year") ///
ytitle("Difference in likelihood of being a student")
